package ua.kharkov.knure.dereza.summarytask4.db.dao;

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;

import ua.kharkov.knure.dereza.summarytask4.db.dto.CardDTO;


/**
 * Basic interface for all CardDAO
 * 
 * @author dereza
 * 
 */
public interface CardDAO {

	/**
	 * Returns a list of client's cards
	 * 
	 * @return List<CardDTO>
	 */
	public List<CardDTO> findClientCards();
	
	/**
	 * Returns a list of client's cards by given client id
	 * 
	 * @param client
	 *            id
	 * @return List<CardDTO>
	 */
	public List<CardDTO> findClientCardsByClientId(int id);

	/**
	 * Return CardDTO by given card id
	 * 
	 * @param id
	 * @return CardDTO
	 */
	public CardDTO findClientCardById(int id);

	/**
	 * Extract CardDTO from resultSet
	 * 
	 * @param rs
	 * @return extracted CardDTO
	 * @throws SQLException
	 */
	public CardDTO extractCardDTO(ResultSet rs) throws SQLException;

	/**
	 * Update balance after withdraw or replenish
	 * 
	 * @param balance
	 * @throws SQLException
	 */
	public void updateBalance(int cardId, BigDecimal balance);

	/**
	 * Updates status with given id
	 * 
	 * @param id
	 * @param statusId
	 */
	public void updateStatus(int id, int statusId);
    
	/**
	 * Updates statuses with given ids 
	 * 
	 * @param ids
	 * @param statusId
	 */
	public void updateStatuses(List<Integer> ids, int statusId);
	
	/**
	 * Commits query and closes connection
	 * 
	 * @param rs
	 * @param ps
	 * @param conn
	 */
	public void commitAndClose(ResultSet rs, Statement ps, Connection conn);

	/**
	 * Rolls back the request
	 * 
	 * @param conn
	 */
	public void rollback(Connection conn);
}